package com.tkjt.pms.modules.kpiAudit.thread;

import com.tkjt.pms.calc.core.AuditStatusWatcher;
import com.tkjt.pms.modules.common.service.TkIndexValueAuditService;

public class MakeMirrorsThread implements Runnable{

    private String mirrorCode;
    private String indexGroup;
    private String dataType;

    private TkIndexValueAuditService tkIndexValueAuditService;
    
    private AuditStatusWatcher auditStatusWatcher;

    public MakeMirrorsThread(String mirrorCode, String indexGroup,String dataType, TkIndexValueAuditService tkIndexValueAuditService, AuditStatusWatcher auditStatusWatcher) {
        this.mirrorCode = mirrorCode;
        this.indexGroup = indexGroup;
        this.dataType = dataType;
        this.tkIndexValueAuditService = tkIndexValueAuditService;
        this.auditStatusWatcher = auditStatusWatcher;
    }

    @Override
    public void run() {
    	auditStatusWatcher.startMirror(mirrorCode, indexGroup, dataType);
        tkIndexValueAuditService.batchDeleteAndSaveEntities(mirrorCode,indexGroup,dataType);
        auditStatusWatcher.endMirror(mirrorCode, indexGroup, dataType);
//        QueryWrapper<TkIndexValueAudit> qw = new QueryWrapper<>();
//        qw.eq("ID",indexValueAuditId);
//        TkIndexValueAudit tkIndexValueAudit = tkIndexValueAuditService.getOne(qw);
//        tkIndexValueAudit.setAuditStatus("3");
//        tkIndexValueAudit.setAuditTime(new Date());
//        try {
//            tkIndexValueAuditService.saveOrUpdate(tkIndexValueAudit);
//        } catch (Exception e) {
//            e.printStackTrace();
//        }
    }
}